

import { Form, Input, InputNumber, Radio, Select } from 'antd';
import { useState } from 'react';
import an58 from '@mmstudio/an000058';
import { Message as M1, Result as R1 } from '../../api/teachgl/add.api';
import api from '../../../atoms/api';
import AddButton from './addbutton';

const { Option } = Select;

export default function Add({ theteacherisqualifiedforthecurriculums=[], trems=[], data }: {
	data: M1;
	theteacherisqualifiedforthecurriculums: Pick<ITbtheteacherisqualifiedforthecurriculum, 'coursename' | 'curriculum_id' | 'teachername' | 'teacher_id'>[];
	trems: Pick<ITbtrem, 'trem_id' | 'trem_name'>[];
}) {
	const [d, setd] = useState({} as M1);
	return <>
		<AddButton dlgtitle='新增' onSave={async () => {
			if (!d
				// || !d.trem_id
				|| !d.coursename
				|| !d.teachername
				|| !d.curriculum_id
				|| !d.teacher_id
				// || !d.trem_name
			) {
				return '缺少必要的参数';
			}
			const res = await an58<R1, M1>(api['/api/teachgl/add'], 'post', d);
			if (res.ok === true) {
				return true;
			}
			return res.message;
		}} >
			<Form.Item required label="课程名称:">
				<Select
					optionFilterProp="children"
					filterOption={(input, option) => {
						return option.children.indexOf(input) >= 0;
					}}
					placeholder='请选择课程名称'
					value={d.curriculum_id}
					onChange={(e) => {
						setd({
							...d,
							curriculum_id: e
						});
					}} >
					{theteacherisqualifiedforthecurriculums.map((it) => {
						return <Select.Option key={it.curriculum_id} value={it.curriculum_id} >{it.coursename}</Select.Option>;
					})}
				</Select>
			</Form.Item>
			<Form.Item required label="星期:">
				 <Select placeholder='请选择星期' onChange={(e) => {
					
				}}>
					<Option value="sun">周日</Option>
					<Option value="mon">周一</Option>
					<Option value="tue">周二</Option>
					<Option value="wen">周三</Option>
					<Option value="thu">周四</Option>
					<Option value="fri">周五</Option>
					<Option value="sat">周六</Option>
    </Select>
			</Form.Item>
			<Form.Item required label="开始节次:">
				<Select placeholder='请选择开始节次' onChange={(e) => {
					
				}}>
					<Option value="1">第1节</Option>
					<Option value="2">第2节</Option>
					<Option value="3">第3节</Option>
					<Option value="4">第4节</Option>
					<Option value="5">第5节</Option>
					<Option value="6">第6节</Option>
					<Option value="7">第7节</Option>
					<Option value="8">第8节</Option>
					<Option value="9">第9节</Option>
					<Option value="10">第10节</Option>
				</Select>
			</Form.Item>
			<Form.Item required label="结束节次:">
				<Select placeholder='请选择结束节次' onChange={(e) => {
					
				}}>
					<Option value="1">第1节</Option>
					<Option value="2">第2节</Option>
					<Option value="3">第3节</Option>
					<Option value="4">第4节</Option>
					<Option value="5">第5节</Option>
					<Option value="6">第6节</Option>
					<Option value="7">第7节</Option>
					<Option value="8">第8节</Option>
					<Option value="9">第9节</Option>
					<Option value="10">第10节</Option>
				</Select>
			</Form.Item>
			<Form.Item required label="教师姓名:">
				<Select
					optionFilterProp="children"
					filterOption={(input, option) => {
						return option.children.indexOf(input) >= 0;
					}}
					placeholder='请选择教师姓名'
					value={d.teacher_id}
					onChange={(e) => {
						setd({
							...d,
							teacher_id: e
						});
					}} >
					{theteacherisqualifiedforthecurriculums.map((it) => {
						return <Select.Option key={it.teacher_id} value={it.teacher_id} >{it.teachername}</Select.Option>;
					})}
				</Select>
			</Form.Item>
			<Form.Item required label="教室名称:">
				<Input placeholder='请输入教室名称' onChange={(e) => {
					
				}} />
			</Form.Item>
			{/* <Form.Item required label="开始教学周:">
				<Select
					optionFilterProp="children"
					filterOption={(input, option) => {
						return option.children.indexOf(input) >= 0;
					}}
					placeholder='请选择开始教学周'
					value={d.group_id}
					onChange={(e) => {
						setd({
							...d,
							group_id: e
						});
					}} >
					{groups.map((it) => {
						return <Select.Option key={it.group_id} value={it.group_id} >{it.groupname}</Select.Option>;
					})}
				</Select>
			</Form.Item>
			<Form.Item required label="结束教学周:">
				<Select
					optionFilterProp="children"
					filterOption={(input, option) => {
						return option.children.indexOf(input) >= 0;
					}}
					placeholder='请选择结束教学周'
					value={d.group_id}
					onChange={(e) => {
						setd({
							...d,
							group_id: e
						});
					}} >
					{groups.map((it) => {
						return <Select.Option key={it.group_id} value={it.group_id} >{it.groupname}</Select.Option>;
					})}
				</Select>
			</Form.Item> */}
		</AddButton>
	</>;
}
